図:VT v.s. オルカン (in NISA)
https://gyazo.com/fa6cec179830fb626897f04274bea3ff
code:main.py
import matplotlib.pyplot as plt
# 定義された条件
annual_growth_rate_ac = 0.05-0.0015
annual_growth_rate_vt = 0.05-0.0007
dividend_rate = 0.02
initial_investment = 10**7
investment_period = 20
us_tax_rate = 0.1
jp_tax_rate = 0.2
# 資産推移を保持するリスト
non_nisa_account_final = 0 # シミュレーション
for year in range(1, investment_period + 1):
dividend_nisa = nisa_account_final-1 * dividend_rate * (1 - us_tax_rate) nisa_growth = nisa_account_final-1 * (1 + annual_growth_rate_vt - dividend_rate) nisa_account_final.append(nisa_growth)
dividend_non_nisa = non_nisa_account_final-1 * dividend_rate # 米国税を差し引く
dividend_non_nisa_after_tax = dividend_non_nisa * (1 - us_tax_rate) * (1 - jp_tax_rate)
# 税額控除のために米国勢を計算しておく
us_tax = dividend_non_nisa * us_tax_rate
# 米国税を差し引いた後の配当を加算
non_nisa_growth = non_nisa_account_final-1 * (1 + annual_growth_rate_vt - dividend_rate) + dividend_non_nisa_after_tax + dividend_nisa + us_tax non_nisa_account_final.append(non_nisa_growth)
regular_growth.append(regular_growth-1 * (1 + annual_growth_rate_ac)) # 相対誤差の計算
# グラフの描画
fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 10))
ax1.plot(nisa_account_final, label="NISA Account (Final)")
ax1.plot(regular_growth, label="Regular Growth (5%)")
ax1.set_ylabel("Amount (JPY)")
ax1.set_title("Investment Simulation Over 20 Years (Final Corrected)")
ax1.legend()
ax1.grid(True)
ax2.plot(relative_error, label="Relative Error (NISA + Non-NISA vs Regular Growth)", color="red")
ax2.set_xlabel("Year")
ax2.set_ylabel("Relative Error (%)")
ax2.set_title("Relative Error Between NISA + Non-NISA and Regular Growth")
ax2.legend()
ax2.grid(True)
plt.tight_layout()
plt.show()